package fuxi2;


import java.util.Scanner;

public class IntArray {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int[] nums=new int[8];
        System.out.println("请输入8个正整数");
        for (int i=0;i< nums.length;i++){
            int n=sc.nextInt();
            nums[i]=n;
        }
        //判断奇偶
        int oddCount=0;//记录奇数
        int evenCount=0; //偶数的个数
        //增强for循环
        for (int num :nums){
            if(num%2==0){
                evenCount++;
                continue;
            }
            oddCount++;
        }
        int[] evenArray=new int[evenCount];//创建偶数数组
        int[] oddArray=new int[oddCount];//创建奇数组
        //放入奇偶数组
        int evenIndex=0;
        int oddIndex=0;
        for (int n:nums){
            if(n%2==0){
                evenArray[evenIndex]=n;
                evenIndex++;
                continue;
            }
            oddArray[oddIndex]=n;
            oddIndex++;
        }
        //交替打印
        for (int i=0;i<nums.length;i++){
            if (i<oddArray.length) {
                System.out.println(oddArray[i]);
            }
            if(i<evenArray.length){
                System.out.println(evenArray[i]);
            }
        }





    }
}
